package org.zhb.sys.shiro.model;

import java.io.Serializable;
import javax.persistence.*;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import java.util.Date;
import java.util.List;

/**
 * The persistent class for the s_user database table.
 * 
 */
@Entity
@Table(name = "s_user")
@DynamicUpdate(true)
public class User implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(unique = true, nullable = false, length = 32)
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(strategy = "uuid", name = "uuid")
	private String id;

	@Column(length = 30)
	private String email;

	@Column(length = 60)
	private String password;

	@Column(length = 11)
	private String phone;

	@Column(name = "real_name", length = 60)
	private String realName;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "register_time")
	private Date registerTime;

	@Column(name = "user_name", length = 60)
	private String userName;

	// bi-directional many-to-one association to UserRole
	@OneToMany(mappedBy = "User")
	private List<UserRole> UserRoles;

	public User() {
	}

	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getRealName() {
		return this.realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public Date getRegisterTime() {
		return this.registerTime;
	}

	public void setRegisterTime(Date registerTime) {
		this.registerTime = registerTime;
	}

	public String getUserName() {
		return this.userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public List<UserRole> getUserRoles() {
		return this.UserRoles;
	}

	public void setUserRoles(List<UserRole> UserRoles) {
		this.UserRoles = UserRoles;
	}

	public UserRole addUserRole(UserRole UserRole) {
		getUserRoles().add(UserRole);
		UserRole.setUser(this);

		return UserRole;
	}

	public UserRole removeUserRole(UserRole UserRole) {
		getUserRoles().remove(UserRole);
		UserRole.setUser(null);

		return UserRole;
	}

}